package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	str4 := "123-456-789"
	var arr = strings.Split(str4, "-")
	fmt.Println(arr)
	var5 := strings.Join(arr, ",")
	fmt.Println(var5)

	var str6 = "Hello 中国"
	fmt.Println([]byte(str6))
	// 遍历字符串，遍历出来的是string后的byte 数组的元素
	for i := 0; i < len(str6); i++ {
		// 遍历出来的是string后的byte 数组的元素
		fmt.Printf("%T %v \n", str6[i], str6[i])
		fmt.Println(string(str6[i]))
	}
	// 遍历字符串，遍历出来的rune数组
	for _, value := range str6 {
		fmt.Printf("%T %v \n", value, string(value))
	}

	// int 与 string 之间的转换
	var str7 = "123"
	var int1, err = strconv.Atoi(str7)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(int1)
	}

	var num = 10
	str8 := strconv.Itoa(num)
	fmt.Println(str8)

	var num2 = 20.121313
	fmt.Printf("%T %v \n", num2, num2)
	str9 := strconv.FormatFloat(num2, 'f', 2, 64)
	fmt.Printf("%T %v \n", str9, str9)

	var num3 int64 = 20
	str10 := strconv.FormatInt(num3, 10)
	fmt.Printf("%T %v \n", str10, str10)

	str11 := strconv.FormatBool(true)
	fmt.Printf("%T %v \n", str11, str11)

	b2 := []byte{97}
	fmt.Println(string(b2))

	r2 := 'a'
	fmt.Println(r2)
}
